<template>
	<view class="index-container">
		<!-- 业务人员 -->
		<view class="business">
			<!-- <image src="../../static/icon/bj.png" mode=""></image> -->
			<view class="task text">
				<text v-if="personType !== 3" :class="currentIndex == 0 ? 'active':''" @click="getMyTicket">我的工单</text>
				<text v-else>工单概况</text>
				<text v-if="personType == 1" style="margin: 0 20rpx;">|</text><text
					:class="currentIndex == 1 ? 'active':''" v-if="personType == 1" @click="getUnitTicket">机构工单</text>
			</view>
			<!-- <view class="text">单位工单</view> -->
			<view class="village" v-if="personType == 3" @click="handleTap('picker')">{{label}}</view>
			<lb-picker ref="picker" mode="selector" :list="unitList" :dataset="{ name: 'label' }" @change="handleChange"
				@confirm="handleConfirm" @cancel="handleCancel">
			</lb-picker>
			<span class="new" @click="goCreateOrder">新建</span>
			<view class="top-icon" @click="goCreateOrder">
				<image src="../../static/icon/xj.png"></image>
			</view>
			<view class="task-num">
				<view class="num-item">
					<view class="num-left">{{total}}</view>
					<view>总工单</view>
				</view>
				<view class="num-item" @click="active = 3">
					<view class="num-center">{{completeLength + overCompleteLength}}</view>
					<view>已完成</view>
				</view>
				<view class="num-item" @click="active = 0">
					<view class="num-right">{{pendLength + handleLength + overTimeLength}}</view>
					<view>待完成</view>
				</view>
			</view>
		</view>
		<view class="search">
			
			<view class="search-box">
				<uni-easyinput  @input="handleInput" :inputBorder="false" prefixIcon="search" v-model="searchText" focus placeholder="请输入搜索条件"></uni-easyinput>
				<!-- <view class="icon">
					<image src="../../static/icon/search.png"></image>
				</view>
				<input v-model="searchText" type="text" @confirm="handleSearch" confirm-type="search"
					class="search-input" placeholder="请输入搜索条件"> -->
				<dean-popover modalLeftPos="-90rpx" isShowIcon :active="active1" @select="selectChange" ref="deanPopover"
					class="pop" :btnList="btnList"></dean-popover>
			</view>
		</view>
		<!-- <view class="navbar">
			<view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }"
			 @click="tabClick(index)">
				{{ item.text + '(' +  item.length +')' }}
			</view>
		</view> -->
		<van-tabs @change="changeTab" color="#1152FC" animated :lazy-render="false" :active="active">
			<van-tab :title-style="active == 0 ? 'color: #1152FC': ''" :title="`待处理(${pendLength})`">
				<view class="bg-box" v-if="ticketList.length">
					<ticket-item :isShowCancel="true" desc="去处理" :ticketList="ticketList"
						@detail="goOrderDetail"></ticket-item>
				</view>

				<view v-else>
					<van-empty description="暂无工单" />
				</view>
				<uni-load-more v-if="ticketList.length >= 5" :status="status" />
			</van-tab>
			<van-tab :title-style="active == 1 ? 'color: #1152FC': ''" :title="`处理中(${handleLength})`">
				<view class="bg-box" v-if="handleList.length">
					<ticket-item :isShowCancel="true"
						v-if="handleList && handleList.length !== 0" desc="去完成" :ticketList="handleList"
						@detail="goOrderDetail"></ticket-item>
				</view>

				<view v-else>
					<van-empty description="暂无工单" />
				</view>
				<uni-load-more v-if="handleList.length >= 5" :status="status1" />
			</van-tab>
			<van-tab :title-style="active == 2 ? 'color: #1152FC': ''" :title="`已超时(${overTimeLength})`">
				<view class="bg-box" v-if="overTimeList.length">
					<ticket-item :isShowCancel="true" desc="去查看" :ticketList="overTimeList" @detail="goOrderDetail">
					</ticket-item>
				</view>

				<view v-else>
					<van-empty description="暂无工单" />
				</view>
				<uni-load-more v-if="overTimeList.length >= 5" :status="status2" />
			</van-tab>
			<van-tab :title-style="active == 3 ? 'color: #1152FC': ''" :title="`正常完成(${completeLength})`">
				<view class="bg-box" v-if="completeList.length">
					<ticket-item :isShowCancel="true" desc="去查看" :ticketList="completeList" @detail="goOrderDetail">
					</ticket-item>
				</view>

				<view v-else>
					<van-empty description="暂无工单" />
				</view>
				<uni-load-more v-if="completeList.length >= 5" :status="status3" />
			</van-tab>
			<van-tab :title-style="active == 4 ? 'color: #1152FC': ''" :title="`超时完成(${overCompleteLength})`">
				<view class="bg-box" v-if="overCompleteList.length">
					<ticket-item :isShowCancel="true" desc="去查看" :ticketList="overCompleteList" @detail="goOrderDetail">
					</ticket-item>
				</view>

				<view v-else>
					<van-empty description="暂无工单" />
				</view>
				<uni-load-more v-if="overCompleteList.length >= 5" :status="status4" />
			</van-tab>
			<van-tab :title-style="active == 5 ? 'color: #1152FC': ''" :title="`已废弃(${abandonLength})`">
				<view class="bg-box" v-if="abandonList.length">
					<ticket-item :isShowCancel="true" desc="去查看" :ticketList="abandonList" @detail="goOrderDetail">
					</ticket-item>
				</view>

				<view v-else>
					<van-empty description="暂无工单" />
				</view>
				<uni-load-more v-if="abandonList.length >= 5" :status="status5" />
			</van-tab>
			<van-tab :title-style="active == 6 ? 'color: #1152FC': ''" :title="`联动中(${assistLength})`">
				<view class="bg-box" v-if="assistList.length">
					<ticket-item :isShowCancel="true" desc="去查看" :ticketList="assistList" @detail="goOrderDetail">
					</ticket-item>
				</view>
			
				<view v-else>
					<van-empty description="暂无工单" />
				</view>
				<uni-load-more v-if="assistList.length >= 5" :status="status6" />
			</van-tab>
		</van-tabs>
		<!-- <view class="record-content" v-if="tabCurrentIndex === 0">
			<ticket-item @cancel="goCancelTicket" :isShowCancel="true" v-if="ticketList && ticketList.length !== 0" desc="去处理" :ticketList="ticketList" @detail="goOrderDetail"></ticket-item>
			<view v-else>
				<van-empty description="暂无工单" />
			</view>
		</view>
		<view class="record-content" v-if="tabCurrentIndex === 1">
			<ticket-item @cancel="goCancelTicket" :isShowCancel="true" v-if="handleList && handleList.length !== 0" desc="处理中" :ticketList="handleList" @detail="goOrderDetail"></ticket-item>
			<view v-else>
				<van-empty description="暂无工单" />
			</view>
		</view>
		<view class="record-content" v-if="tabCurrentIndex === 2">
			<ticket-item :isShowCancel="true" v-if="completeList && completeList.length !== 0" desc="已完成" :ticketList="completeList" @detail="goOrderDetail"></ticket-item>
			<view v-else>
				<van-empty description="暂无工单" />
			</view>
		</view>
		<view class="record-content" v-if="tabCurrentIndex === 3">
			<ticket-item :isShowCancel="true" v-if="abandonList && abandonList.length !== 0" desc="已废弃" :ticketList="abandonList" @detail="goOrderDetail"></ticket-item>
			<view v-else>
				<van-empty description="暂无工单" />
			</view>
		</view> -->
	</view>
</template>

<script>
	import LbPicker from '@/components/lb-picker'
	import TicketItem from '@/components/ticketItem'
	import DeanPopover from '@/components/dean-popover/dean-popover.vue'
	import {
		mapState,
		mapMutations,
		mapGetters
	} from 'vuex'
	import dayjs from 'dayjs'
	export default {
		components: {
			DeanPopover,
			TicketItem,
			LbPicker
		},
		data() {
			return {
				isFocus: true,
				status: 'more',
				status1: 'more',
				status2: 'more',
				status3: 'more',
				status4: 'more',
				status5: 'more',
				status6: 'more',
				pendLength: 0,
				handleLength: 0,
				overTimeLength: 0,
				completeLength: 0,
				overCompleteLength: 0,
				abandonLength: 0,
				assistLength: 0,
				active: 0,
				active1: 0,
				num: 0,
				allUnitList: [],
				label: '全部单位',
				value: '',
				unitList: [{
					id: null,
					label: '全部单位',
					value: '全部单位'
				}],
				list: [],
				currentIndex: 0,
				tabCurrentIndex: 0,
				navList: [{
						text: '待处理',
						total: 0,
						length: 0
					},
					{
						text: '处理中',
						total: 0,
						length: 0
					},
					{
						text: '已完成',
						total: 0,
						length: 0
					},
					{
						text: '已废弃',
						total: 0,
						length: 0
					},
				],
				params: {
					接单人id: null,
					联系人姓名: '',
					联系人电话: '',
					报事人类型: 3,
					工单状态: 'pending',
					条件组合: 1,
					所属单位: null,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "id",
						order: 0
					}
				},
				params1: {
					接单人id: null,
					联系人姓名: '',
					联系人电话: '',
					报事人类型: 3,
					工单状态: 'handling',
					条件组合: 1,
					所属单位: null,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "id",
						order: 0
					}
				},
				params2: {
					接单人id: null,
					联系人姓名: '',
					联系人电话: '',
					报事人类型: 3,
					所属单位: null,
					工单状态: 'completed',
					条件组合: 1,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "完成时间",
						order: 0
					}
				},
				params3: {
					接单人id: null,
					联系人姓名: '',
					联系人电话: '',
					报事人类型: 3,
					所属单位: null,
					工单状态: 'abandoned',
					条件组合: 1,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "废弃时间",
						order: 0,
					}
				},
				params4: {
					条件组合: 1,
				},
				params5: {
					接单人id: null,
					联系人姓名: '',
					联系人电话: '',
					报事人类型: 3,
					工单状态: 'timeout',
					条件组合: 1,
					所属单位: null,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "id",
						order: 0
					}
				},
				params6: {
					接单人id: null,
					联系人姓名: '',
					联系人电话: '',
					报事人类型: 3,
					工单状态: 'completedwithtimeout',
					条件组合: 1,
					所属单位: null,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "id",
						order: 0
					}
				},
				params7: {
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "ProcessTime",
						order: 0
					}
				},
				ticketList: [],
				pendList: [],
				handleList: [],
				completeList: [],
				abandonList: [],
				overTimeList: [],
				overCompleteList: [],
				assistList: [],
				ticketType: this.$type.ticketType,
				allTicketList: [],
				haveMoreTicket: true,
				haveMoreComplete: true,
				haveMoreOver: true,
				haveMoreOverComplete: true,
				haveMoreHandle: true,
				haveMoreAbandon: true,
				haveMoreAssist: true,
				searchText: '',
				btnList: ['全部', '装修申请', '装修验收', '故障报修', '上门回收', '消防安全', '保洁清理', '设备安装', '绿化养护', '意见投诉', '网格社工'],
				flag: false,
				ticketTypeList: ['', 'G', 'H', 'A', 'B', 'C', 'D', 'E', 'F', 'I', 'J'],
				userId: null,
				timerId: null
			}
		},
		onLoad() {
			this.getAllTicketList()
			// this.
			// if (!uni.getStorageSync('login')) {
			// 	this.showModal()
			// }
		},
		onShow() {
			console.log('unit', this.isUnitTicket)
			this.userId = uni.getStorageSync('userInfo').id
			if (uni.getStorageSync('login')) {
				// this.getAdminTicket()
				if (this.personType == 3) {
					let unitNameList = uni.getStorageSync('userInfo').所属单位名称
					let unitIdList = uni.getStorageSync('userInfo').所属单位
					unitNameList.forEach((item, index) => {
						this.unitList.push({
							id: unitIdList[index],
							label: item,
							value: item
						})
					})
					uni.setStorageSync('unitList', this.unitList)
					this.getAdminTicket()
				} else if (this.isUnitTicket) {
					this.getUnitTicket()
				} else {
					// this.userId = uni.getStorageSync('userInfo').id
					this.init(this.userId)
					this.searchText = ''
					this.initCurrent()
					this.$refs.deanPopover.currentIndex = 0
					this.initList()
					// this.getUserInfo()
				}
			}
			// this.getUserInfo()
		},
		computed: {
			...mapState(['isResetSum', 'isUnitTicket']),
			...mapGetters(['personType']),
			total() {
				return this.pendLength + this.handleLength + this.completeLength + this.overTimeLength + this
					.overCompleteLength + this.abandonLength
			}

		},
		onReachBottom() {
			if (this.active === 0 && this.haveMoreTicket) {
				this.status = 'loading'
				this.getMoreTicketList()
			} else if (this.active === 1 && this.haveMoreHandle) {
				this.status1 = 'loading'
				this.getMoreHandleList()
			} else if(this.active === 2 && this.haveMoreOver) {
				this.status2 = 'loading'
				this.getMoreOver()
			} else if (this.active === 3 && this.haveMoreComplete) {
				this.status3 = 'loading'
				this.getMoreComplete()
			} else if (this.active === 4 && this.haveMoreOverComplete) {
				this.status4 = 'loading'
				this.getMoreOverComplete()
			}else if(this.active === 5 && this.haveMoreAbandon) {
				this.status5 = 'loading'
				this.getMoreAbandon()
			}else if(this.active === 6 && this.haveMoreAssist) {
				this.status6 = 'loading'
				this.getMoreAssist()
			}
		},
		// watch: {
		// 	searchText() {
		// 		if (this.searchText == '') {
		// 			if (this.personType == 3) {
		// 				this.initAdminParams()
		// 				return
		// 			}
		// 			this.initParams('')
		// 			this.initList()
		// 		}
		// 	}
		// },
		methods: {
			...mapMutations(['resetSum', 'setPersonType', 'setTicketType']),
			handleInput() {
				clearTimeout(this.timerId)
				this.timerId = setTimeout(() => {
					this.initParams(this.searchText)
					this.initList()
				}, 600)
				
			},
			resetSearch() {
				this.searchText = ''
			},
			changeTab(name, title) {
				this.active = name.target.index
			},
			initList() {
				this.getTicketList()
				this.getHandleList()
				this.getCompleteList()
				this.getOverTime()
				this.getOverComplete()
				this.getAbandonList()
				this.getAssistList()
			},
			getAdminTicket() {
				this.$http2.post('ticketSystem/ticket/list', this.params4).then(res => {
					console.log(res)
					if (res.code === 10000) {
						console.log(res)

						if (res.data.list !== null) {
							this.allUnitList = res.data.list
							this.ticketList = res.data.list.filter(item => item.工单状态 == 'pending')
							this.navList[0].total = this.ticketList.length
							this.navList[0].length = this.ticketList.length
							this.handleList = res.data.list.filter(item => item.工单状态 == 'handling')
							this.navList[1].total = this.handleList.length
							this.navList[1].length = this.handleList.length
							this.completeList = res.data.list.filter(item => item.工单状态 == 'completed')
							this.navList[2].total = this.completeList.length
							this.navList[2].length = this.completeList.length
							this.abandonList = res.data.list.filter(item => item.工单状态 == 'abandoned')
							this.navList[3].total = this.abandonList.length
							this.navList[3].length = this.abandonList.length
							return
						}
						this.ticketList = []
						this.handleList = []
						this.completeList = []
						this.abandonList = []
						this.navList.forEach(item => {
							item.length = 0
						})
					}
				})
			},
			getAllUnitTicket() {
				this.currentIndex = 1
				this.haveMoreTicket = true,
					this.haveMoreComplete = true,
					this.haveMoreHandle = true,
					this.haveMoreAbandon = true,
					this.setTicketType(true)
				this.resetSum(true)
				this.getTicketList()
			},
			getUnitTicket() {
				this.currentIndex = 1
				this.haveMoreTicket = true
				this.haveMoreComplete = true
				this.haveMoreHandle = true
				this.haveMoreAbandon = true
				this.setTicketType(true)
				this.init(null)
				const id = uni.getStorageSync('currentUnitId')
				this.params.所属机构 = 0
				this.params1.所属机构 = 0
				this.params2.所属机构 = 0
				this.params3.所属机构 = 0
				this.params5.所属机构 = 0
				this.params6.所属机构 = 0
				this.resetSum(true)
				this.initList()
			},
			getMyTicket() {
				this.currentIndex = 0
				this.$refs.deanPopover.currentIndex = 0
				this.haveMoreTicket = true,
					this.haveMoreComplete = true,
					this.haveMoreHandle = true,
					this.haveMoreAbandon = true,
					this.setTicketType(false)
				// console.log('我的')
				this.init(this.userId)
				this.resetSum(true)
				this.initList()
			},
			init(val) {
				this.params = {
					接单人id: val,
					联系人姓名: '',
					联系人电话: '',
					报事人类型: 3,
					所属单位: null,
					工单状态: 'pending',
					条件组合: 1,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "id",
						order: 0
					}
				}
				this.params1 = {
					接单人id: val,
					联系人姓名: '',
					联系人电话: '',
					报事人类型: 3,
					所属单位: null,
					工单状态: 'handling',
					条件组合: 1,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "处理时间",
						order: 0
					}
				}
				this.params2 = {
					接单人id: val,
					联系人姓名: '',
					联系人电话: '',
					报事人类型: 3,
					所属单位: null,
					工单状态: 'completed',
					条件组合: 1,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "完成时间",
						order: 0
					}
				}
				this.params3 = {
					接单人id: val,
					联系人姓名: '',
					联系人电话: '',
					报事人类型: 3,
					所属单位: null,
					工单状态: 'abandoned',
					条件组合: 1,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "废弃时间",
						order: 0,
					}
				}
				this.params5 = {
					接单人id: val,
					联系人姓名: '',
					联系人电话: '',
					报事人类型: 3,
					工单状态: 'timeout',
					条件组合: 1,
					所属单位: null,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "id",
						order: 0
					}
				}
				this.params6 = {
					接单人id: val,
					联系人姓名: '',
					联系人电话: '',
					报事人类型: 3,
					工单状态: 'completedwithtimeout',
					条件组合: 1,
					所属单位: null,
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "id",
						order: 0
					}
				}
				this.params7 = {
					pagination: {
						current: 1,
						pageSize: 10
					},
					sorter: {
						field: "ProcessTime",
						order: 0
					}
				}
			},
			setTabCurrentIndex(val) {
				this.tabCurrentIndex = val
			},
			initCurrent() {
				this.params.pagination.current = 1
				this.params1.pagination.current = 1
				this.params2.pagination.current = 1
				this.params3.pagination.current = 1
				this.params5.pagination.current = 1
				this.params6.pagination.current = 1
				this.params7.pagination.current = 1
			},
			// 获取所有工单
			getAllTicketList() {
				this.params.工单状态 = null
				this.$http2.post('ticketSystem/ticket/list', this.params).then(res => {
					console.log(res, '所有')
					if (res.code === 10000) {
						this.allTicketList = res.data.list
						// this.total = res.data.total
					}
				})
			},
			
			// 获取工单列表
			getTicketList() {
				// this.setTicketType(false)
				// uni.showLoading()
				this.params.工单状态 = 'pending'
				this.$http2.post('ticketSystem/ticket/list', this.params).then(res => {
					console.log(res, '待完成')
					if (res.code === 10000) {
						this.pendLength = res.data.total
						if (res.data.list !== null) {
							res.data.list.forEach(item => {
								item.创建时间 = dayjs(item.创建时间).format('YYYY-MM-DD HH:mm:ss')
							})
						}
						this.ticketList = res.data.list || []
						if (this.isResetSum) {
							this.navList[0].total = res.data.total
						}
						this.navList[0].length = res.data.total
					}
				})
			},
			// 获取处理中
			getHandleList() {
				// this.params.工单状态 = 'handling'
				this.$http2.post('ticketSystem/ticket/list', this.params1).then(res => {
					console.log(res)
					if (res.code === 10000) {
						this.handleLength = res.data.total
						if (res.data.list !== null) {
							res.data.list.forEach(item => {
								item.创建时间 = dayjs(item.创建时间).format('YYYY-MM-DD HH:mm:ss')
							})
						}
						this.handleList = res.data.list || []
						if (this.isResetSum) {
							this.navList[1].total = res.data.total
						}
						this.navList[1].length = res.data.total
					}
				})
			},
			// 获取已完成
			getCompleteList() {
				// this.params.工单状态 = 'completed'
				this.$http2.post('ticketSystem/ticket/list', this.params2).then(res => {
					console.log(res, '已完成')
					if (res.code === 10000) {
						this.completeLength = res.data.total
						if (res.data.list !== null) {
							res.data.list.forEach(item => {
								item.创建时间 = dayjs(item.创建时间).format('YYYY-MM-DD HH:mm:ss')
							})
						}
						this.completeList = res.data.list || []
						if (this.isResetSum) {
							this.navList[2].total = res.data.total
						}
						this.navList[2].length = res.data.total
					}
				})
			},
			// 获取超时
			getOverTime() {
				this.$http2.post('ticketSystem/ticket/list', this.params5).then(res => {
					if (res.code === 10000) {
						this.overTimeLength = res.data.total
						// console.log(res, '超时')
						this.overTimeList = res.data.list || []
					}
				})
			},
			// 获取超时完成
			getOverComplete() {
				this.$http2.post('ticketSystem/ticket/list', this.params6).then(res => {
					if (res.code === 10000) {
						this.overCompleteLength = res.data.total
						// console.log(res, '超时')
						this.overCompleteList = res.data.list || []
					}
				})
			},
			// 获取已废弃
			getAbandonList() {
				// this.params.工单状态 = 'abandoned'
				this.$http2.post('ticketSystem/ticket/list', this.params3).then(res => {
					// console.log(res, '废弃')
					if (res.code === 10000) {
						this.abandonLength = res.data.total
						if (res.data.list !== null) {
							res.data.list.forEach(item => {
								item.创建时间 = dayjs(item.创建时间).format('YYYY-MM-DD HH:mm:ss')
							})
						}
						this.abandonList = res.data.list || []
						if (this.isResetSum) {
							this.navList[3].total = res.data.total
							// this.isSum = false
							this.resetSum(false)
						}
						this.navList[3].length = res.data.total
					}
				})
			},
			getAssistList() {
				this.$http2.post('ticketSystem/assist/tickets', this.params7).then(res => {
					if (res.code === 10000) {
						this.assistLength = res.data.total
						// console.log(res, '超时')
						this.assistList = res.data.list || []
					}
				})
			},
			// 更多协助
			getMoreAssist() {
				this.params7.pagination.current++
				this.$http2.post('ticketSystem/assist/tickets', this.params7).then(res => {
					if(res.code === 10000) {
						if (res.data.list == null) {
							this.haveMoreAssist = false
							this.status6 = 'noMore'
							return
						}
						this.assistList = this.assistList.concat(res.data.list)
					}
				})
			},
			// 更多待完成
			getMoreTicketList() {
				this.params.工单状态 = 'pending'
				this.params.pagination.current++
				this.$http2.post('ticketSystem/ticket/list', this.params).then(res => {
					console.log(res, '加载更多')
					if (res.code === 10000) {
						if (res.data.list == null) {
							this.haveMoreTicket = false
							this.status = 'noMore'
							return
						}
						this.ticketList = this.ticketList.concat(res.data.list)
					}
				})
			},
			// 更多处理中
			getMoreHandleList() {
				this.params1.工单状态 = 'handling'
				this.params1.pagination.current++
				this.$http2.post('ticketSystem/ticket/list', this.params1).then(res => {
					console.log(res, '加载更多')
					if (res.code === 10000) {
						if (res.data.list == null) {
							this.haveMoreHandle = false
							this.status1 = 'noMore'
							return
						}
						this.handleList = this.handleList.concat(res.data.list)
					}
				})
			},
			// 更多超时
			getMoreOver() {
				// this.params5.工单状态 = 'timeout'
				this.params5.pagination.current++
				this.$http2.post('ticketSystem/ticket/list', this.params5).then(res => {
					console.log(res, '更多超时')
					if (res.code === 10000) {
						if (res.data.list == null) {
							this.haveMoreOver = false
							this.status2 = 'nomore'
							return
						}
						this.overTimeList = this.overTimeList.concat(res.data.list)
					}
				})
			},
			// 更多超时完成
			getMoreOverComplete() {
				this.params6.工单状态 = 'completedwithtimeout'
				this.params6.pagination.current++
				this.$http2.post('ticketSystem/ticket/list', this.params6).then(res => {
					// console.log(res, '加载更多')
					if (res.code === 10000) {
						if (res.data.list == null) {
							this.haveMoreoverComplete = false
							this.status4 = 'noMore'
							return
						}
						this.overCompleteList = this.overCompleteList.concat(res.data.list)
					}
				})
			},
			// 更多完成
			getMoreComplete() {
				this.params2.工单状态 = 'completed'
				// uni.showLoading()
				this.params2.pagination.current++
				this.$http2.post('ticketSystem/ticket/list', this.params2).then(res => {
					console.log(res, '加载更多')
					if (res.code === 10000) {
						if (res.data.list == null) {
							this.haveMoreComplete = false
							this.status3 = 'noMore'
							return
						}
						this.completeList = this.completeList.concat(res.data.list)
					}
				})
			},
			// 更多废弃
			getMoreAbandon() {
				this.params3.工单状态 = 'abandoned'
				uni.showLoading()
				this.params3.pagination.current++
				this.$http2.post('ticketSystem/ticket/list', this.params3).then(res => {
					console.log(res, '加载更多')
					if (res.code === 10000) {
						if (res.data.list == null) {
							this.haveMoreAbandon = false
							this.status5 = 'noMore'
							return
						}
						this.abandonList = this.abandonList.concat(res.data.list)
					}
				})
			},
			showModal() {
				uni.showModal({
					title: '提示',
					content: '您还没有登录,请登录后使用',
					success: function(res) {
						if (res.confirm) {
							uni.navigateTo({
								url: '/ticketSystem/verify/verify'
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
			goCommunityNews() {
				uni.navigateTo({
					url: '../communityNews/communityNews'
				})
			},
			tabClick(index) {
				this.tabCurrentIndex = index
				this.params.pagination.current = 1
				this.params1.pagination.current = 1
				this.params2.pagination.current = 1
				this.params3.pagination.current = 1
			},
			goOrderDetail(id) {
				uni.navigateTo({
					url: '/ticketSystem/orderDetail/orderDetail?id=' + id
				})
			},
			handleSearch() {
				if (this.personType == 3) {
					this.initAdminParams(this.searchText)
					return
				}
				this.initParams(this.searchText)
				this.initList()
			},
			initAdminParams(val) {
				this.params4.工单状态 = ''
				this.params4.联系人姓名 = val
				this.params4.联系人电话 = val
				this.params4.工单编号 = val
				this.params4.报事位置 = val
				this.getAdminTicket()
			},
			goCreateOrder() {
				if (uni.getStorageSync('login')) {
					uni.navigateTo({
						url: '/ticketSystem/createOrder/createOrder'
					})
				} else {
					uni.navigateTo({
						url: '/ticketSystem/verify/verify'
					})
				}
			},
			selectChange(val) {
				// console.log(val)
				if (this.personType == 3) {
					this.params4.工单筛选类型 = this.ticketTypeList[val]
					this.getAdminTicket()
					return
				}
				this.params.工单筛选类型 = this.ticketTypeList[val]
				this.params1.工单筛选类型 = this.ticketTypeList[val]
				this.params2.工单筛选类型 = this.ticketTypeList[val]
				this.params3.工单筛选类型 = this.ticketTypeList[val]
				this.params5.工单筛选类型 = this.ticketTypeList[val]
				this.params6.工单筛选类型 = this.ticketTypeList[val]
				this.params7.ticketType = this.ticketTypeList[val]
				this.initList()
			},
			initParams(val) {
				// this.params.工单状态 = ''
				this.params.联系人姓名 = val
				this.params1.联系人姓名 = val
				this.params2.联系人姓名 = val
				this.params3.联系人姓名 = val
				this.params5.联系人姓名 = val
				this.params6.联系人姓名 = val
				this.params.联系人电话 = val
				this.params1.联系人电话 = val
				this.params2.联系人电话 = val
				this.params3.联系人电话 = val
				this.params5.联系人电话 = val
				this.params6.联系人电话 = val
				this.params.工单编号 = val
				this.params1.工单编号 = val
				this.params2.工单编号 = val
				this.params3.工单编号 = val
				this.params5.工单编号 = val
				this.params6.工单编号 = val
				this.params.报事位置 = val
				this.params1.报事位置 = val
				this.params2.报事位置 = val
				this.params3.报事位置 = val
				this.params5.报事位置 = val
				this.params6.报事位置 = val
			},
			handleTap(name) {
				this.$refs[name].show()
			},
			handleChange(e) {
				console.log('change::', e)
			},
			handleConfirm(e) {
				// 如果存在多个picker，可以在picker上设置dataset属性，confirm中获取，就能区分是哪个picker了
				console.log('confirm::', e)
				if (e) {
					const name = e.dataset.name
					const label = e.item.label
					if (name && label) {
						this[name] = label
					}
					uni.showLoading({
						mask: true
					})
					setTimeout(function() {
						uni.hideLoading()
					}, 400)
					if (e.item.id === null) {
						console.log('触发')
						this.getAdminTicket()
						return
					}
					this.ticketList = this.allUnitList.filter(item => item.工单状态 == 'pending' && item['接单单位id'] == e.item
						.id)
					this.navList[0].total = this.ticketList.length
					this.navList[0].length = this.ticketList.length
					this.handleList = this.allUnitList.filter(item => item.工单状态 == 'handling' && item['接单单位id'] == e.item
						.id)
					this.navList[1].total = this.handleList.length
					this.navList[1].length = this.handleList.length
					this.completeList = this.allUnitList.filter(item => item.工单状态 == 'completed' && item['接单单位id'] == e
						.item.id)
					this.navList[2].total = this.completeList.length
					this.navList[2].length = this.completeList.length
					this.abandonList = this.allUnitList.filter(item => item.工单状态 == 'abandoned' && item['接单单位id'] == e.item
						.id)
					this.navList[3].total = this.abandonList.length
					this.navList[3].length = this.abandonList.length
					// this.operatorList = this.allUnitList.filter(item => item['接单单位id'] == e.item.id)
				}
			},
			handleCancel(e) {
				console.log('cancel::', e)
			}
		}
	}
</script>

<style lang="scss">
	.uni-easyinput {
		width: 540rpx!important;
	}
	.bg-box {
		min-height: 62vh;
		background-color: #f5f5f5;
	}

	.van-empty {
		background-color: #fff;
	}

	.index-container {
		// background-color: #F5f5f5;
		// min-height: 100vh;
		// padding-bottom: 100rpx;
		.banner {
			width: 750rpx;
			height: 360rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.nav {
			width: 750rpx;
			height: 346rpx;
			padding-bottom: 40rpx;
			display: flex;
			flex-wrap: wrap;
			border-bottom: 2rpx solid #f5f5f5;

			// background-color: pink;
			.nav-item {
				width: 150rpx;
				height: 150rpx;

				.item-img {
					width: 80rpx;
					height: 80rpx;
					margin: 23rpx 0 10rpx 34rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.item-text {
					margin-left: 20rpx;
					font-size: 28rpx;
				}
			}
		}

		.notice {
			height: 42rpx;
			margin-top: 28rpx;
			margin-left: 20rpx;
			padding-left: 11rpx;
			line-height: 42rpx;
			border-left: 8rpx solid #1064E9;
			;
			margin-bottom: 30rpx;

			.title {
				font-size: 36rpx;
				margin-right: 419rpx;
			}

			.more {
				color: #1064E9;
				font-size: 28rpx;
			}
		}

		.notice-item {
			width: 670rpx;
			height: 134rpx;
			margin-left: 40rpx;
			position: relative;
			padding-left: 20rpx;
			margin-bottom: 14rpx;
			border-bottom: 2rpx solid #ECECEC;

			&::before {
				content: '';
				position: absolute;
				width: 16rpx;
				height: 16rpx;
				border-radius: 50%;
				background-color: #5472FF;
				left: -8rpx;
				top: 0;
			}

			.item-content {
				color: #333;
				font-size: 26rpx;
				margin-bottom: 10rpx;

				.item-more {
					margin-left: 4rpx;
					color: #666;
				}
			}

			.time {
				color: #999;
				font-size: 24rpx;
			}
		}

		.business {
			background: #1152FC;

			.new {
				color: #fff;
				position: absolute;
				top: 37rpx;
				right: 80rpx;
			}

			position: relative;
			width: 750rpx;
			height: 260rpx;

			image {
				width: 100%;
				height: 100%;
			}

			.task {
				position: absolute;
				color: #fff;
				font-size: 32rpx;
				top: 37rpx;
				left: 59rpx;
			}

			.active {
				color: #e5e200;
			}

			.top-icon {
				position: absolute;
				top: 37rpx;
				right: 21rpx;
				width: 42rpx;
				height: 46rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.task-num {
				height: 100rpx;
				position: absolute;
				left: 0;
				right: 0;
				bottom: 40rpx;
				display: flex;

				// background-color: pink;
				.num-item {
					flex: 1;

					// padding-left: 80rpx;
					view {
						display: flex;
						justify-content: center;
						font-size: 24rpx;
						color: #fff;
					}

					.num-left {
						color: #F2FF63;
						font-size: 40rpx;
					}

					.num-center {
						color: #32C836;
						font-size: 40rpx;
					}

					.num-right {
						color: #FCC25E;
						font-size: 40rpx;
					}
				}
			}

			.village {
				width: 164rpx;
				height: 60rpx;
				line-height: 60rpx;
				position: absolute;
				padding-left: 10rpx;
				right: 200rpx;
				top: 28rpx;
				// border: 2rpx solid #FFFFFF;
				border-radius: 2rpx;
				color: #fff;
				font-size: 28rpx;

				&:after {
					position: absolute;
					width: 16rpx;
					height: 16rpx;
					right: 10rpx;
					border-top: 2rpx solid #fff;
					border-right: 2rpx solid #fff;
					transform: rotate(135deg);
					top: 16rpx;
					content: '';
				}
			}
		}

		.search {
			align-items: center;
			// margin-left: 100rpx;
			padding-left: 60rpx;
			width: 750rpx;
			height: 96rpx;
			background-color: #fff;
			display: flex;
			border: 2rpx solid #f5f5f5;
			align-items: center;
			// justify-content: center;
			position: relative;

			// padding-left: 50rpx;
			.search-box {
				align-items: center;
				width: 564rpx;
				height: 56rpx;
				padding-left: 17rpx;
				padding-right: 10rpx;
				color: #999;
				// background-color: pink;
				border: 2rpx solid #595959;
				border-radius: 28rpx;
				display: flex;

				//position: relative;
				.icon {
					width: 50rpx;
					height: 46rpx;
					margin-top: 3rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.search-input {
					flex: 1;
					height: 100%;
					color: #999;
					position: relative;
				}

				.clear-icon {
					width: 44rpx;
					height: 44rpx;
					color: #fff;
					border-radius: 50%;
					line-height: 40rpx;
					text-align: center;
					margin-top: 4rpx;
					// align-items: center;
					// position: absolute;
					// right: 130rpx;
					// top: 24rpx;
					background-color: #c8c9cc;
				}
			}

			.pop {
				position: absolute;
				right: 40rpx;
			}
		}

		.navbar {
			display: flex;
			height: 40px;
			padding: 0 5px;
			background: #fff;
			// box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
			position: relative;
			z-index: 10;
			// border-bottom: 2rpx solid #eee;
			border-bottom: 2rpx solid #FAFAFA;

			.nav-item {
				flex: 1;
				display: flex;
				justify-content: center;
				align-items: center;
				height: 100%;
				font-size: 28rpx;
				color: #666;
				position: relative;

				&.current {
					color: #1152FC;

					&:after {
						content: '';
						position: absolute;
						left: 50%;
						bottom: 0;
						transform: translateX(-50%);
						width: 120rpx;
						height: 0;
						border-bottom: 2px solid #1152FC;
					}
				}
			}
		}

		.record-content {
			.van-empty {
				background-color: #fff;
			}

			.record-item {
				width: 690rpx;
				height: 282rpx;
				background-color: #fff;
				box-shadow: 0px 1rpx 11rpx 1rpx #EEEEEE;
				border-radius: 8rpx;
				margin-top: 20rpx;
				margin-left: 30rpx;

				.item-title {
					display: flex;
					justify-content: space-between;
					padding-right: 20rpx;
					width: 100%;
					height: 71rpx;
					display: flex;
					align-items: center;
					border-bottom: 2rpx solid #eee;
					position: relative;

					// padding-top: 10rpx;
					.left-border {
						width: 6rpx;
						height: 30rpx;
						background-color: #1064E9;
						position: absolute;
						left: 0;
						top: 20rpx;
					}

					.left {
						padding-left: 30rpx;
						color: #333;
						font-weight: bold;
						// margin-right: 230rpx;
					}

					.right {
						color: #333;
						font-size: 28rpx;
					}

					.compete {
						color: #83D065;
						width: 82rpx;
						height: 36rpx;
						font-size: 22rpx;
						border: 2rpx solid #83D065;
						text-align: center;
					}
				}

				.item-content {
					color: #666;
					padding: 30rpx;
					font-size: 28rpx;

					.content-top {
						margin-bottom: 16rpx;
						display: flex;
						justify-content: space-between;

						.handle {
							width: 82rpx;
							height: 36rpx;
							background: #1152FC;
							color: #fff;
							font-size: 22rpx;
							text-align: center;

						}
					}

					.content-center {
						margin-bottom: 10rpx;
						display: flex;
						justify-content: space-between;

						.transfer {
							width: 82rpx;
							height: 36rpx;
							// background: #1152FC;
							color: #1152FC;
							font-size: 22rpx;
							border: 2rpx solid #1152FC;
							text-align: center;
						}
					}

					.content-bottom {
						display: flex;
						justify-content: space-between;

						.address {
							overflow: hidden; //超出的隐藏
							text-overflow: ellipsis; //省略号
							white-space: nowrap; //强制一行显示
						}

						.transfer {
							width: 82rpx;
							height: 36rpx;
							// background: #1152FC;
							color: #1152FC;
							font-size: 22rpx;
							border: 2rpx solid #1152FC;
							text-align: center;
						}
					}
				}
			}
		}
	}
</style>
